<html>
<head>
<link rel="stylesheet" type="text/css"  href="common.css"/>
<script type="text/javascript" src="jquery-1.12.0.js"></script>
<script type="text/javascript" src="common.js"></script>
</head>
<body>

<form>
  数字验证<br/> 
 <input type="text" name="id" />  <br/><br/>
 分组，URL检测验证<br/>
 <input type="text" name="name" /><br/><br/>
 长度验证<br/>
 <input type="text" name="title" /><br/><br/>
 提交时验证<br/> 
 <input type="text" name="address" /><br/><br/>

 <input type="submit"  value="提交"/>
</form>




<script type="text/javascript">
$(function(){

  $('form').validator({
	submit:function(){		
		alert('提交');
		return false;
	},
    valids:{
	  id:{
		require:true,
		rules:[
			{regex:/^\d+$/,msg:'必须是数字'},
			{min:10,max:999,msg:'范围10~99'}
		]
		},
	  name:{
		require:true,
		rules:[
			{minlen:1,maxlength:20,msg:'长度1~20个字符。'},
			{regex:/^[\u4e00-\u9fa5a-zA-Z][\u4e00-\u9fa5a-zA-Z\s]{0,}$/,msg:'必须是汉字或英文开头'},
			{group:'name',regex:/^[\u4e00-\u9fa5][\u4e00-\u9fa5]{0,9}$/,msg:'或，纯中文10个字,不含空格'},
			{group:'name',regex:/^[a-zA-Z][a-zA-Z\s]{0,19}$/,msg:'或，必须是汉字或英文开头，含空格'},
			{remote:'',msg:'去服务器检测一下'}	
		]
	  },	  
	  title:{
		require:true,
		rules:[
			{minlen:1,maxlen:20,msg:'长度1~20个字符。'},
			{regex:/^[\u4e00-\u9fa5a-zA-Z][\u4e00-\u9fa5a-zA-Z\s]{0,}$/,msg:'必须是汉字或英文开头'}
		]
	  },
	  address:{
	   isfocus:false,
	   require:true,
	   rules:[
			{minlen:1,maxlength:20,msg:'长度1~20个字符。'},
			{regex:/^[\u4e00-\u9fa5a-zA-Z][\u4e00-\u9fa5a-zA-Z\s]{0,}$/,msg:'必须是汉字或英文开头'},
			{group:'name',regex:/^[\u4e00-\u9fa5][\u4e00-\u9fa5]{0,9}$/,msg:'或，纯中文10个字,不含空格'},
			{group:'name',regex:/^[a-zA-Z][a-zA-Z\s]{0,19}$/,msg:'或，必须是汉字或英文开头，含空格'}
	   ]
	  }
	}
  });
});
</script>
</body>
</html>